package io.github.kouleen.manager.domain;


import io.github.kouleen.minecraft.core.utils.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;

/**
 * @author zhangqing
 * @since 2025/1/25 20:26
 */
public enum ColourTypeEnum {

    BLACK("§0", "黑色"),
    DARK_BLUE("§1", "深蓝"),
    DARK_GREEN("§2", "深绿"),
    SKY_BLUE("§3", "天蓝"),
    RED("§4", "红色"),
    DARK_PURPLE("§5", "深紫"),
    GOLDEN("§6", "金黄"),
    LIGHT_GREY("§7", "浅灰"),
    DARK_GREY("§8", "深灰"),
    LIGHT_PURPLE("§9", "淡紫"),
    LIGHT_GREEN("§a", "浅绿"),
    LIGHT_BLUE("§b", "淡蓝"),
    LIGHT_RED("§c", "淡红"),
    LILAC("§d", "淡紫"),
    LIGHT_GOLDEN("§e", "淡黄"),
    WHITE("§f", "白色");

    private final String colour;

    private final String message;

    ColourTypeEnum(String colour, String message) {
        this.colour = colour;
        this.message = message;
    }

    public String getColour() {
        return colour;
    }

    public String getMessage() {
        return message;
    }

    public static List<String> getColourList(){
        return Arrays.stream(ColourTypeEnum.values()).map(ColourTypeEnum::getColour).distinct().collect(Collectors.toList());
    }

    public static String getRandomColour(String message,Random random) {
        if (!StringUtils.hasText(message)){
            return "";
        }
        List<String> colourList = getColourList();
        int index = random.nextInt(colourList.size());
        return colourList.get(index) + message;
    }
}
